package com.hk.aefz.controller;

import com.hk.aefz.config.Uploadconfig;
import com.hk.aefz.service.UploadFileService;
import io.swagger.annotations.Authorization;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping(path = "/uploadfile")
public class UploadFileController {

    @Autowired
    private UploadFileService uploadFileService;

    @PostMapping(path = "/image")
    public Map<String,Object> uploadFile(@RequestParam("upload") MultipartFile upload) throws IOException, InterruptedException {
        Map<String,Object> map = new HashMap<>();
        String surl = uploadFileService.UploadFile(upload);
        System.out.println("路径:"+surl); //将图片路径存入map
        map.put("surl",surl);
        return map;
    }

}
